package cn.fan.iot.mqtt;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * MQTT客户端创建
 *
 *
 */
@Component
public class MqttClientCreate {

    @Resource
    private MqttClientManager MqttClientManager;

    @Autowired
    private MqttConfig mqttConfig;

    /**
     * 创建MQTT客户端
     */
    @PostConstruct
    public void createMqttClient() {
        //创建客户端，客户端ID：demo，回调类跟客户端ID一致
        MqttClientManager.createMqttClient(mqttConfig.getClientId(), mqttConfig.getSubscribeTopic(), mqttConfig.getUserName(), mqttConfig.getPassword());

    }
}